package cn.whitecao.agent.server.controller;

import cn.whitecao.agent.server.model.CollectDataModel;
import cn.whitecao.agent.server.service.DataCenterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 接收上报数据
 *
 * @author : BashfulHuang
 **/
@RestController
@RequestMapping("/agent/report")
public class ReportController {
    // TODO: 接口秘钥校验 header 参数都行
    @Autowired
    private DataCenterService dataCenterService;
    @PostMapping("")
    public void report(@RequestBody List<CollectDataModel> list){
       dataCenterService.batchSave(list);
        // list.forEach(System.out::println);

    }
}

